 <!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>{$Think.config.site.title} - 配送管理</title>

    <meta name="keywords" content="{$Think.config.site.keywords}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>
<style>
#listtable .fa{
	cursor:pointer;
	color:#1ab394;
	margin-right:1em;
}
th .tag{font-size: 12px; color: #e66c6c; font-weight: normal;}
.ibox-title .tag{font-size: 12px; color: #e66c6c; font-weight: normal; display: inline-block; margin-left: 20px;}
.specval-hide{display: none;}

.td-big-btop{border-top: 2px solid #999 !important;}
</style>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
      <div class="row">
            <div class="col-sm-4">
                <button type="button"  class="btn btn-primary btn-sm webPrintf"><i class="fa fa-share-alt "></i> 打印</button>
            </div>
      </div>
      <div class="row">
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>待出库订单列表</h5>
                        <!-- <span class="tag">说明：</span> -->
                    </div>
                    <div class="ibox-content">
                        <!-- <div class="row">
                        	<div class="col-sm-6">
                        	</div>
                          	<div class="col-sm-6">
                                <div class="input-group pull-right">
                                <form action="{:url('index')}" method="get" enctype="application/x-www-form-urlencoded">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入关键词" class="input-sm form-control" value="{$Think.get.keywords ?? ''}" name="keywords">
                                    <input type="hidden" class="create_time" name="create_time" value="">
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                                </form>
                                </div>
                            </div>
                            
                        </div> -->
                        <div class="table-responsive">
                            <table class="table " id="listtable"> <!-- table-striped -->
                                <thead>
                                    <tr>
                                        <th width="30">
                                            <input name="checkall" id="checkall"  type="checkbox" class="i-checks" value="1">
                                        </th>
                                        <th width="150">订单号</th>
                                        <th width="150">收货人</th>
                                        <th width="150">收货人电话</th>
                                        <th width="">收获地址</th>
                                        <th width="100">商品数量</th>
                                        <th width="100">库存数量</th>
                                        <th width="100">能否配送</th>
                                        <th width="100">配送员</th>
                                        <th width="150" class="create_time_sort" data-create_time_sort='{$create_time}'>下单时间 {if condition='$create_time eq "create_time desc"'}<span>&darr;</span>{else /}<span>&uarr;</span>{/if}</th>
                                        <th width="150">支付方式</th>
                                    </tr>
                                </thead>
                                <tbody>

                                	{volist name="list" id="vo"}
                                    <tr data-id="{$vo.order_id}" data-shipping_id="{$vo.shipping_id}" style="background-color: #f9f9f9;">
                                        <td class="td-big-btop">
                                            <input name="ids[]"  type="checkbox" class="i-checks" value="{$vo.order_id}" {if(!$vo['finish'])} disabled="disabled" {/if}>
                                        </td>
                                        <td class="td-big-btop">{$vo.order_no}</td>
                                        <td class="td-big-btop">{$vo.receiver_name}</td>
                                        <td class="td-big-btop">{$vo.receiver_mobile}</td>
                                        <td class="td-big-btop">{$vo.receiver_pcd}{$vo.receiver_address}</td>
                                        <td class="td-big-btop"></td>
                                        <td class="td-big-btop"></td>
                                        <td class="td-big-btop">
                                        {if($vo['finish'])}
                                            <!-- <button type="button" class="btn btn-primary btn-xs btn-allot">可配送</button> -->
                                            <!-- <a href='{:url("allot",["order_id"=>$vo["order_id"]])}' class="btn btn-primary btn-xs ">可配送</a> -->
                                            <a href="{:url('shipping/allot',['step'=>2,'order_id'=>$vo['order_id']],'')}" class="btn btn-primary btn-xs ">可配送</a>
                                            
                                        {else}
                                            <button type="button" class="btn btn-default btn-xs">不可配送</button>
                                        {/if}
                                        </td>
                                        <td class="td-big-btop">{$vo.delivery_name}</td>
                                        <td class="td-big-btop">{$vo.create_time}</td>
                                        <td class="td-big-btop">{$vo.pay_platform}</td>
                                    </tr>
                                    {volist name="vo['list']" id="vv" key="n"}
                                    <tr data-spevcal_id="{$vv.goods_specval_id}">
                                        {if($n==1)}
                                        <td rowspan="{:sizeof($vo['list'])}" colspan="3">
                                            商品信息
                                        </td>
                                        {/if}
                                        <td><img src="{$vv.goods_picture}" width="30" height="30"></td>
                                        <td>{if condition="$vv.brand_name!=''"}（{$vv.brand_name}）{/if}{$vv.goods_name}【{$vv.goods_specval_name}】</td>
                                        <td>{$vv.num}</td>
                                        <td>{$vv.stock_num}</td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    {/volist}
                                    {/volist}

                                </tbody>
                            </table>
                        </div>
                        <div>{$page}</div>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/majax.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/jedit.js"></script>
</body>

</html>
<script>
//切换排序
$('.create_time_sort').click(function(){
    var create_time_sort = $(this).data('create_time_sort');
    if(create_time_sort == "create_time desc"){
        $('.create_time').val("create_time asc");
    }else{
        $('.create_time').val("create_time desc");
    }
    $('form').submit();
})

var layer_font='';
$(document).ready(function() {
	
	$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});

	//全选
	$("#checkall").bind("ifChecked",function(){
		$("input[name='ids[]']").iCheck("check");
	});
	//取消全选
	$("#checkall").bind("ifUnchecked",function(){
		$("input[name='ids[]']").iCheck("uncheck");
	});
	//顶部按钮
    $("#nestable-menu").on("click",
    function(e) {
        var target = $(e.target),
        action = target.data("action");

		//保存排序
        if (action === "allot") {
            var list = [],goods='';
			$("input[name='ids[]']:checked").each(function(index, element) {
				list.push($(this).closest("tr").data("id"));
				
			});
			if(list.length < 1) {
				layer.msg('请至少选中一项', {icon: 5});
				return false;
			}
			
			layer_font = layer.open({
				type: 2,
				title: '选择配送员',
				shadeClose: true,
				shade: 0.8,
				area: ['900px', '90%'],
				content: '{:url("allot")}', //iframe的url
				btn: ['确定', '取消'],
				btn1: function(index, layero){
					var d = $('iframe',layero)[0].contentDocument;
					var uid = $("input[name='uid']:checked",d).val();
					if(uid == undefined) {
						layer.msg('未选择配送员', {icon: 2});
						layer.close(index);
						return false;
					}
					majax('{:url("allot")}',{uid:uid,ids:list.join(',')},function(d){
						if (d.code<=0) {
							layer.msg(d.msg, {icon: 5});
							layer.close(index);
						}
					})
				}
		  	});
        }

    });
});

$('.webPrintf').click(function(){
    var ids = [];
    var id = $('input[name="ids[]"]:checked').not('[disabled="disabled"]').each(function(){
        ids.push($(this).closest('tr').data('shipping_id'))
    })
    console.log(ids)
    if (ids.length==0) {
        layer.msg('至少选择一项',{icon:2});
        return false;
    }
    autoPrint(ids.join(','));
})

function autoPrint(id) {
    layer_font = layer.open({
        type: 2,
        title: '打印',
        shadeClose: true,
        shade: 0.8,
        end: function(){window.location.reload(true)},
        area: ['900px', '90%'],
        content: '{:url("webPrintf")}?ids='+id, //iframe的url
    });
}


function closeIfram(){
    layer.close(layer_font);
}
</script>